package com.edais.dao;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.edais.domain.BannerConfigTab;
import com.edais.domain.UserActivityKeyCode;
import com.edais.domain.UserActivityUpFrozenInfo;
import com.edais.domain.UserLDActivityInfo;
import com.edais.persistence.ActivityMapper;

@Repository

public class ActivityDao {
	
	@Autowired
	private ActivityMapper activityMapper;
	/**
	 * 获取app版本信息
	 * @param params
	 * @return
	 */
	public List getAppVersionInfoList(Map<String, String> params){		
		List retList = new ArrayList();		
		List<Map<String, Object>> appVersionInfoList = activityMapper.getAppVersionInfoList(params);		
		if(appVersionInfoList != null && appVersionInfoList.size() > 0){	
			for(int i = 0; i < appVersionInfoList.size(); i++){			
				Map tmp = appVersionInfoList.get(i);
				Map<String, Object> retMap = new HashMap<String, Object>();
				retMap.put("appVersion", tmp.get("APP_VERSION"));
				retMap.put("osName", tmp.get("OS_NAME"));
				retMap.put("downloadUrl", tmp.get("DOWNLOAD_URL"));
				retMap.put("updateDesc", tmp.get("UPDATE_DESC"));
				retMap.put("updateType", tmp.get("UPDATE_TYPE"));				
				retMap.put("createDate", tmp.get("CREATE_DATE"));
				retMap.put("lastUpdateDate", tmp.get("LAST_UPDATE_DATE"));
				retMap.put("inreview", tmp.get("IN_REVIEW"));
				retMap.put("readyforsale", tmp.get("READY_FOR_SALE"));
				
				retList.add(retMap);
			}
		}
		return retList;		
	}
	/**
	 * 获取app版本信息总条数
	 * @param params
	 * @return
	 */
	public int getAppVersionInfoListCount(Map<String, String> params){
		
		return this.activityMapper.getAppVersionInfoListCount(params);
	}
	
	public List<BannerConfigTab> getBannerList(Map<String, Object> params) throws Exception{
		return this.activityMapper.getBannerList(params);
	}
	
	public List getBannerListSEC() throws Exception{
		return this.activityMapper.getBannerListSEC();
	}
	
	/**
	 * 获取参数列表
	 * @param listStr
	 * @return
	 * @throws Exception
	 */
	public List queryParamName(List<String> listStr) throws Exception {
		return activityMapper.queryParamName(listStr);
	}
	
	/**
	 * 获取K码数据
	 * @param listStr
	 * @return
	 * @throws Exception
	 */
	public List<UserActivityKeyCode> findKeyCodeListByParm(Map<String, Object> map) throws Exception {
		return activityMapper.findKeyCodeListByParm(map);
	}
	
	/**
	 * 根据卡号查询K码数据
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Map<String,Object> findKeyCodeByCardNo(Map<String, Object> map) throws Exception {
		return activityMapper.findKeyCodeByCardNo(map);
	}
	/**
	 * 获取K码使用数据
	 * @param listStr
	 * @return
	 * @throws Exception
	 */
	public List<UserLDActivityInfo> findActivityInfoByParm(Map<String, Object> map) throws Exception {
		return activityMapper.findActivityInfoByParm(map);
	}
	
	public void addActivityInfo(UserLDActivityInfo activityInfo) throws Exception {
		activityMapper.addActivityInfo(activityInfo);
	}

	public void updateActivityInfo(UserLDActivityInfo activityInfo) throws Exception {
		activityMapper.updateActivityInfo(activityInfo);
	}

	public Map<String, Object> findActivityBidInfo() throws Exception {
		return activityMapper.findActivityBidInfo();
	}
	
	public void executeCreateActivityBid(Map<String, Object> map) throws Exception {
		activityMapper.executeCreateActivityBid(map);
	}

	public void updateActivityInfoIsValid(UserLDActivityInfo activityInfo) throws Exception {
		activityMapper.updateActivityInfoIsValid(activityInfo);
	}
	
	/**
	 * 根据条件更新活动历史记录表
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public int updateActivityHistoryInfoByParm(Map<String,Object> map) throws Exception {
		return activityMapper.updateActivityHistoryInfoByParm(map);
	}

	/**
	 * 增加活动历史记录
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public void addActivityHistoryInfo(Map<String,Object> map) throws Exception {
		activityMapper.addActivityHistoryInfo(map);
	}

	/**
	 * 查询活动历史记录
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Map<String,Object> queryActivityHistoryInfoByParm(Map<String,Object> map) throws Exception {
		return activityMapper.queryActivityHistoryInfoByParm(map);
	}
	
	/**
	 * 根据卡号查询用户活动K码一览表
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public UserActivityKeyCode queryUserActivityKeyCodeByCardNo(Map<String, Object> map) throws Exception{
		return activityMapper.queryUserActivityKeyCodeByCardNo(map);
	}
	
	/**
	 * 更新用户活动K码一览表信息
	 * @param userActivityKeyCode
	 * @return
	 * @throws Exception
	 */
	public int updateUserActivityKeyCodeInfo(UserActivityKeyCode userActivityKeyCode)throws Exception{
		return activityMapper.updateUserActivityKeyCodeInfo(userActivityKeyCode);
	}
	
	/**
	 * 增加用户活动K码一览表信息
	 * @param userActivityKeyCode
	 * @throws Exception
	 */
	public void addUserActivityKeyCodeInfo(UserActivityKeyCode userActivityKeyCode)throws Exception{
		activityMapper.addUserActivityKeyCodeInfo(userActivityKeyCode);
	}
	
	/**
	 * 根据条件查询 预冻结数据
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public UserActivityUpFrozenInfo queryUserUpForzenInfoByParm(Map<String,Object> map)throws Exception{
		return activityMapper.queryUserUpForzenInfoByParm(map);
	}

	/**
	 * 添加预冻结数据
	 * @param info
	 * @throws Exception
	 */
	public void addUserUpForzenInfo(UserActivityUpFrozenInfo info)throws Exception{
		activityMapper.addUserUpForzenInfo(info);
	}

	/**
	 * 更新预冻结数据
	 * @param info
	 * @throws Exception
	 */
	public int updateUserUpForzenInfo(UserActivityUpFrozenInfo info)throws Exception{
		return activityMapper.updateUserUpForzenInfo(info);
	}
	public List<BannerConfigTab> getAcList(Map<String, Object> map) throws Exception{
		return activityMapper.getAcList(map);
	}
	public int getAcListCount() throws Exception{
		// TODO Auto-generated method stub
		return activityMapper.getAcListCount();
	}

	/**
	 * 
	* 添加微商推送数据
	* @param  userActivityKeyCode
	* @return void   
	* @throws Exception
	 */
	public void addWbActivityKeyCodeData(Map<String, Object> map)throws Exception{
		activityMapper.addWbActivityKeyCodeData(map);
	}
	
	/**
	 * 
	* 添加微商推送数据
	* @param  userActivityKeyCode
	* @return void   
	* @throws Exception
	 */
	public int getActivityChannelIdByOrderTime(Date orderTime) throws Exception{
		return activityMapper.getActivityChannelIdByOrderTime(orderTime);
	}
	
	/**
	 * lock t_user_activity_history_info by user id
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	public int updateForLock(Long userId) throws Exception{
		return activityMapper.updateForLock(userId);
	}
}
